import Main from '../layout/main.vue'
import Util from '../libs/util'

export const loginRouter = {
  path: '/login',
  name: 'login',
  meta: {
    title: '登录'
  },
  beforeEnter: (to, from, next) => {
  if (Util.user()
 )
{
  next({
    name: 'home_index'
  })
}
else
{
  next()
}
},
component: () =>import('../pages/login.vue')
}

export const page404 = {
  path: '/*',
  name: 'error_404',
  meta: {
    title: '404-页面不存在'
  },
  component: () => import('../pages/errors/error_404.vue')
}

export const page403 = {
  path: '/403',
  name: 'error_403',
  meta: {
    title: '403-权限不足'
  },
  component: () => import('../pages/errors/error_403.vue')
}

export const appRouter = [
  {
    path: '/home',
    name: 'home',
    component: Main,
    meta: {
      requireAuth: true,
      icon: 'ios-speedometer',
      title: '首页'
    },
    children: [
      {
        path: 'index',
        name: 'home_index',
        meta: {
          icon: 'ios-speedometer',
          title: '首页'
        },
        component: () => import('../pages/home/home.vue')
  }
]
},
{
  path: '/rbac',
    name: 'rbac',
  component: Main,
  meta: {
  requireAuth: true,
    icon: 'android-bookmark',
    title: '权限设置',
    requirePermission: 'RoleManager'
},
  children: [
    {
      path: 'index',
      name: 'rbac_index',
      meta: {
        icon: 'android-bookmark',
        breadCrumbs: [{name: '权限设置', href: '/rbac/index', active: true}],
        title: '权限设置',
        requirePermission: 'RoleManager'
      },
      component: () => import('../pages/rbac/index.vue')
}
]
},
{
  path: '/admin',
    name:'admin',
    component:Main,
    meta:
  {
    requireAuth: true,
      icon:'person-stalker',
      title:'组织队伍管理',
      requirePermission: 'userManager'
      // requirePermission:'create-admin'
  },
  children: [
    {
      path: 'organization',
      name: 'organization_index',
      meta: {
        icon: 'person-stalker',
        breadCrumbs: [{name: '调解组织管理', href: '/admin/organization', active: true}],
        title: '调解组织管理',
        requirePermission: 'organizationManager'
      },
      component: () => import('../pages/organization/index.vue')
  },
  {
    path: 'mediator',
      name: 'mediator_index',
    meta: {
    icon: 'person',
      breadCrumbs: [{name: '调解员管理', href: '/admin/mediator', active: true}],
      title: '调解员管理',
      requirePermission: 'mediatorManager'
  },
    component: () => import('../pages/mediator/index.vue')
  },
  {
    path: 'financial_staff',
      name: 'financial_staff_index',
    meta: {
    icon: 'person',
      breadCrumbs: [{name: '财务人员管理', href: '/admin/financial_staff', active: true}],
      title: '财务人员管理',
      requirePermission: 'financialManager'
  },
    component: () => import('../pages/financialStaff/index.vue')
  },
  {
    path: 'judicial_officers',
      name: 'judicial_officers_index',
    meta: {
    icon: 'person',
      breadCrumbs: [{name: '司法机关人员管理', href: '/admin/judicial_officers', active: true}],
      title: '司法机关人员管理',
      requirePermission: 'judicialManager'
  },
    component: () => import('../pages/judicialOfficers/index.vue')
  },
  {
    path: 'training-application',
      name: 'training_application_index',
    meta: {
    icon: 'clipboard',
      breadCrumbs: [{name: '培训申请管理', href: '/admin/training-application', active: true}],
      title: '培训申请管理',
      requirePermission: 'trainingApplication'
  },
    component: () => import('../pages/trainingApplication/index.vue')
  },
  {
  path: 'organization-commendation',
    name: 'organization_commendation_index',
    meta: {
    icon: 'ribbon-b',
      breadCrumbs: [{name: '组织荣誉管理', href: '/admin/organization-commendation', active: true}],
      title: '组织荣誉管理',
    requirePermission: 'organizationCommendation'
  },
  component: () => import('../pages/organizationCommendation/index.vue')
},
  {
    path: 'mediator-commendation',
      name: 'mediator_commendation_index',
    meta: {
    icon: 'ribbon-a',
      breadCrumbs: [{name: '调解员表彰管理', href: '/admin/mediator-commendation', active: true}],
      title: '调解员表彰管理',
    requirePermission: 'mediatorCommendation'
  },
    component: () => import('../pages/mediatorCommendation/index.vue')
  },
  {
    path: 'funding-protection',
      name: 'funding_protection_index',
    meta: {
    icon: 'stats-bars',
      breadCrumbs: [{name: '经费保障统计管理', href: '/admin/funding-protection', active: true}],
      title: '经费保障统计管理',
    requirePermission: 'fundingProtection'
  },
    component: () => import('../pages/fundingProtection/index.vue')
  },
]

},

{
  path: '/daily',
    name: 'daily',
  component: Main,
  meta: {
  requireAuth: true,
    icon: 'android-options',
    title: '日常事务管理',
    requirePermission: 'daily'
},
  children: [
    {
      path: 'case-statistics',
      name: 'case_statistics',
      meta: {
        icon: 'ios-bookmarks-outline',
        breadCrumbs: [{name: '案件情况统计', href: '/daily/case-statistics', active: true}],
        title: '案件情况统计',
        requirePermission: 'caseStatistics'
      },
      component: () => import('../pages/caseStatistics/index.vue')
},
  {
    path: 'subsidy-application',
      name: 'subsidy_application',
    meta: {
    icon: 'ios-bookmarks-outline',
      breadCrumbs: [{name: '补贴申请', href: '/daily/subsidy-application', active: true}],
      title: '补贴申请',
      requirePermission: 'subsidyApplication'
  },
    component: () => import('../pages/subsidyApplication/index.vue')
  }
,
  {
    path: 'training-situation',
      name: 'training_situation',
    meta: {
    icon: 'ios-book-outline',
      breadCrumbs: [{name: '培训情况', href: '/daily/training-situation', active: true}],
      title: '培训情况',
      requirePermission: 'trainingSituation'
  },
    component: () => import('../pages/trainingSituation/index.vue')
  }
]
},
{
  path: '/case',
    name:'case',
  component:Main,
  meta:
  {
    requireAuth: true,
      icon:'ios-paper-outline',
    title:'案件办理管理',
    requirePermission: 'caseManager'
    // requirePermission:'create-admin'
  },
  children: [
    {
      path: 'create-case/:caseId?/:step?',
      props: true,
      name: 'case_create',
      meta: {
        icon: 'social-foursquare-outline',
        breadCrumbs: [{name: '新增案件', href: '/case/create-case', active: true}],
        title: '新增案件',
        requirePermission: 'caseCreateManager'
      },
      component: () => import('../pages/caseCreate/index.vue')
},
  {
    path: 'index/:refresh?',
      props: true,
      name: 'case_index',
    meta: {
    icon: 'ios-paper',
      breadCrumbs: [{name: '案件管理', href: '/case/index', active: true}],
      title: '案件管理',
      requirePermission: 'caseInfoManager'
  },
    component: () => import('../pages/case/index.vue')
  },
  {
    path: 'subsidy-accounting',
      name: 'subsidy_accountingn',
    meta: {
    icon: 'levels',
      breadCrumbs: [{name: '补贴核算', href: '/case/subsidy-accounting', active: true}],
      title: '补贴核算',
      requirePermission: 'subsidyAccounting'
  },
    component: () => import('../pages/subsidyAccounting/index.vue')
  }
,
]
},
{
  path: '/knowledge',
    name: 'knowledge',
  component: Main,
  meta: {
  requireAuth: true,
    icon: 'ios-bookmarks-outline',
    title: '知识库管理',
    requirePermission: 'knowledge'
},
  children: [
    {
      path: 'index',
      name: 'knowledge_index',
      meta: {
        icon: 'ios-bookmarks-outline',
        breadCrumbs: [{name: '典型案例', href: '/knowledge/index', active: true}],
        title: '典型案例',
        requirePermission: 'classicCase'
      },
      component: () => import('../pages/classicCase/index.vue')
},
  {
    path: 'law',
      name: 'knowledge_law',
    meta: {
    icon: 'ios-bookmarks-outline',
      breadCrumbs: [{name: '法律法规', href: '/knowledge/law', active: true}],
      title: '法律法规',
      requirePermission: 'law'
  },
    component: () => import('../pages/law/index.vue')
  }
,
  {
    path: 'explain',
      name: 'knowledge_explain',
    meta: {
    icon: 'ios-book-outline',
      breadCrumbs: [{name: '司法解释', href: '/knowledge/explain', active: true}],
      title: '司法解释',
      requirePermission: 'explain'
  },
    component: () => import('../pages/explain/index.vue')
  }
]
},
]

export const routers = [
    loginRouter,
    ...appRouter,
  page403,
  page404,
  ]

